﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using ItemStatistics.Models;


namespace ItemStatistics.ViewModels.ReciveInfoVMs
{
    public partial class ReciveInfoListVM : BasePagedListVM<ReciveInfo_View, ReciveInfoSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"", dialogWidth: 800).SetQueryString($"pid={Searcher.CustomerId}"),
                this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "", dialogWidth: 800),
                //this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "", dialogWidth: 800),
                //this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "", dialogWidth: 800),
                //this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "", dialogWidth: 800),
                this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "", dialogWidth: 800),
                this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "", dialogWidth: 800),
                  

                //this.MakeStandardAction("ReciveInfo", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], ""),
            };
        }


        protected override IEnumerable<IGridColumn<ReciveInfo_View>> InitGridHeader()
        {
            return new List<GridColumn<ReciveInfo_View>>{
                this.MakeGridHeader(x => x.Name_view,90),
                this.MakeGridHeader(x => x.Name_view2,90),
                this.MakeGridHeader(x => x.Number,60),

                this.MakeGridHeader(x => x.CreateTime,150).SetTitle("领取时间"),
                this.MakeGridHeaderAction(width: 90)
            };
        }

        public override IOrderedQueryable<ReciveInfo_View> GetSearchQuery()
        {
            var query = DC.Set<ReciveInfo>()
                .CheckEqual(Searcher.CustomerId, x=>x.CustomerId)
                .CheckEqual(Searcher.GiftId, x=>x.GiftId)
                .Select(x => new ReciveInfo_View
                {
				    ID = x.ID,
                    Name_view = x.Customer.Name,
                    Name_view2 = x.Gift.Name,
                    Number = x.Number,
                    CreateTime = x.CreateTime
                })
                .OrderBy(x => x.Name_view);
            return query;
        }

    }

    public class ReciveInfo_View : ReciveInfo{
        [Display(Name = "姓名")]
        public String Name_view { get; set; }
        [Display(Name = "礼品名称")]
        public String Name_view2 { get; set; }

    }
}
